package com.example.mapper;


import com.example.dto.BookDishDTO;
import com.example.dto.CategoryDTO;
import com.example.entity.User;
import com.example.vo.BookDishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface UserMapper {


    /**
     * 根据openid查询用户
     * @param openid
     * @return
     */
    @Select("select * from user where openid=#{openid}")
    User getByOpenid(String openid);

    /**
     * 插入数据
     * @param user
     */
    void insert(User user);

    /**
     * 用户端查询图书分类
     * @return
     */
    @Select("select * from category")
    List<CategoryDTO> getCategory();

    /**
     * 查询每个分类下的所有图书
     * @param categoryId
     * @return
     */
    @Select("select * from bookdish where category_id=#{categoryId}")
    List<BookDishVO> getBookDish(Integer categoryId);

    /**
     * 查询新增用户
     * @param beginTime
     * @param endTime
     * @return
     */
    Integer sumUser(LocalDateTime beginTime, LocalDateTime endTime);

    /**
     * 查询所有用户
     * @param endTime
     * @return
     */
    Integer sumUserAll(LocalDateTime endTime);
}
